const { spawn } = require('child_process');

let child;

// 定义启动程序的函数
function startApp() {
  child = spawn('start.bat');

  child.stdout.on('data', function (data) {
    // console.log('stdout: ' + data);
  });

  child.stderr.on('data', function (data) {
    console.error('stderr: ' + data);
  });

  child.on('close', function (code) {
    console.log('child process exited with code ' + code);
    // 当被监控的程序退出时，重新启动它
    startApp();
  });
}

// 启动程序
startApp();
